package thread;

public class ThreadDemo {
    public static void main(String[] args) throws InterruptedException {
        Thread t=new Thread(()->{
            int n=5;
            for(int i=0;i<n;i++)
            {
                System.out.println("我是一个线程,正在工作中");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        t.start();
        t.join();//该操作让线程结束
        System.out.println("这是主线程, 期望这个日志在 t 结束后打印");
    }
}
